package com.xyzwps.orm.ormlite.repository;

import com.j256.ormlite.dao.Dao;
import com.xyzwps.orm.model.Tag;
import com.xyzwps.orm.repository.TablesRepository;

import java.sql.SQLException;
import java.util.Objects;

public class OrmLiteTablesRepository implements TablesRepository {

    private final Dao<Tag, Integer> tagDao;

    public OrmLiteTablesRepository(Dao<Tag, Integer> tagDao) {
        this.tagDao = Objects.requireNonNull(tagDao);
    }

    @Override
    public void cleanAllTables() {
        try {
            tagDao.deleteBuilder().delete();
        } catch (SQLException ex) {
            throw new IllegalStateException(ex);
        }
    }

}
